package com.lrkj.back.vo;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import sun.net.ftp.FtpClient;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Iterator;
import java.util.List;

/**
 * Created by daiwe on 2017/6/13.
 */
public class TDOC {

    public static void main(String args[]) {
        try {

            FtpClient ftp = null;
            SocketAddress addr = new InetSocketAddress("192.168.192.9", 21);
            ftp = FtpClient.create();
            ftp.connect(addr);
            InputStream is = null;
            FileOutputStream fos = null;
            ftp.login("thsoft", "1234".toCharArray());
            ftp.setBinaryType();
            try {

                is = ftp.getFileStream("11.xml");
                SAXReader reader = new SAXReader();
                Document document = reader.read(is);
                // 得到xml根元素
                Element root = document.getRootElement();
                Element logdata = root.element("LOGDATA");
                Element foo;
                for (Iterator i = root.elementIterator("VALUE"); i.hasNext();) {
                    foo = (Element) i.next();
                    foo.elementText("MACHREFNO");
                }
                // 得到根元素的所有子节点
                List<Element> elementList = root.elements();
                // 遍历所有子节点
                byte[] bytes = new byte[1024];

            } catch (Exception e) {
                e.printStackTrace();
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }

    }

}
